<template>
	<el-card shadow="hover">
		<template v-slot:header>
			发文待办
			<div style="float: right;display: inline-flex">
				<sc-icon style="cursor: pointer;width: 18px; margin-right: 10px;" @click="reLoadBpm" title="刷新"><el-icon-refresh-right/></sc-icon>
				<sc-icon style="cursor: pointer;width: 18px;" @click="getMoreBpm" title="全部"><el-icon-more-filled/></sc-icon>
			</div>
		</template>
		<div style="height: 210px;text-align: center;">
			<el-table :data="bpmList" style="width: 100%" :show-header="false" @row-click="handleBpm" class="customer-table">
				<el-table-column prop="flowTitle" :show-overflow-tooltip="true">
					<template #default="scope">
						<div v-if="scope.row.recTime==''||scope.row.recTime==undefined" style="position: absolute;"><sc-icon-new/></div>
							<span style="margin-right: 10px">NO:{{scope.row.id}}</span>{{scope.row.flowTitle}}
					</template>
				</el-table-column>
				<el-table-column prop="stepName" width="100" align="center"></el-table-column>
				<el-table-column prop="createUser" width="100" align="center">
					<template #default="scope">
							{{scope.row.createUser}}
					</template>
				</el-table-column>
				<el-table-column prop="createTime" width="180" align="center">
					<template #default="scope">
							{{scope.row.createTime}}
					</template>
				</el-table-column>
			</el-table>
		</div>
	</el-card>
</template>

<script>
export default {
	components: {
	},
	data() {
		return {
			bpmList:[],
			dialog: {
				detailsSave:false,
			},
			timer:null
		}
	},
	created() {
		clearInterval(this.timer)
		this.timer = null
	},
	beforeUnmount() {
		clearInterval(this.timer);
		this.timer = null
	},
	mounted() {
		this.getMyBpmDoWorkListForDesk();
		this.setTimer();
	},
	methods: {
		reLoadBpm()
		{
			this.getMyBpmDoWorkListForDesk();
		},
		getMoreBpm(){
			this.$nextTick(() => {
				this.$router.replace({
					path: '/doc/docsend/approval',
				})
			})
		},
		async getMyBpmDoWorkListForDesk(){
			var res = await this.$API.bpm.bpmStepRun.getMyBpmDoWorkListForDesk.get({model:'1',isDoc:'1'});
			if (res.code == 200) {
				this.bpmList = res.data
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		handleBpm(row,index)
		{
			this.$nextTick(() => {
				this.$router.replace({
					path: '/doc/handle/dowork',
					query:{
						runId:row.runId,
						stepRunId:row.stepRunId,
						flowId:row.flowId
					}
				})
			})
		},
		setTimer() {
			if(this.timer == null) {
				this.timer = setInterval( () => {
					this.getMyBpmDoWorkListForDesk();
				}, this.$TOOL.data.get("MSG_TIME"))
			}
		}
	}
}
</script>
<style scoped>
:deep(.el-table tr){
	cursor: pointer;
}
.customer-table th {
	border: none;
}

.customer-table td, .customer-table th.is-leaf {
	border: none;
}

.el-table--border, .el-table--group {
	border: none;
}

.customer-table thead tr th.is-leaf {
	border: 1px solid #EBEEF5;
	border-right: none;
}

.customer-table thead tr th:nth-last-of-type(2) {
	border-right: 1px solid #EBEEF5;
}

.el-table--border::after, .el-table--group::after {
	width: 0;
}

.customer-table::before {
	width: 0;
}

.customer-table .el-table__fixed-right::before, .el-table__fixed::before {
	width: 0;
}

.el-table--border th.gutter:last-of-type {
	border: 1px solid #EBEEF5;
	border-left: none;
}
</style>
